home *** CD-ROM | disk | FTP | other *** search
- /*
- * RADIO.C - Radio communications manager module
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <dtypes.h>
-
- #include "tiles.h"
-
- #include "host.h"
- #include "newload.h"
- #include "callasm.h"
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void clear_channel(p_CHANNEL c)
- * PURPOSE : Clear all messages on a channel
- * :
- * CREATION: 02/10/1989 09:29:46
- */
- void clear_channel(p_CHANNEL c)
- {
- c->head=c->tail=0;
- } /* void clear_channel(p_CHANNEL c) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void add_message_to_channel(p_CHANNEL c, int n1, int n2, int n3)
- * PURPOSE : Append message n1,n2,n3 to channel C
- * :
- * CREATION: 02/10/1989 09:37:28
- */
- void add_message_to_channel(p_CHANNEL c, int n1, int n2, int n3)
- {
- if (peek_ahead(c->head)==c->tail)
- return;
-
- c->message[c->head].note1=n1;
- c->message[c->head].note2=n2;
- c->message[c->head].note3=n3;
-
- inc_pointer(&c->head);
-
- } /* void add_message_to_channel(p_CHANNEL c, int n1, int n2, int n3) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> int peek_ahead(int p)
- * PURPOSE : What would the next pointer increment normally be?
- * :
- * CREATION: 02/10/1989 09:45:38
- */
- int peek_ahead(int p)
- {
- p++; if (p>=MAX_MESSAGES) p=0;
- return p;
- } /* int peek_ahead(int p) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void inc_pointer(int *p)
- * PURPOSE : Increment queue head or tail pointer to next position
- * :
- * CREATION: 02/10/1989 09:46:39
- */
- void inc_pointer(int *p)
- {
-
- (*p)++; if ((*p) >= MAX_MESSAGES) (*p)=0;
-
- } /* void inc_pointer(int *p) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void read_message(p_CHANNEL c, int *n1, int *n2, int *n3)
- * PURPOSE : Read message from channel C and place results
- * : in n1, n2, and n3
- * CREATION: 02/10/1989 10:06:01
- */
- void read_message(p_CHANNEL c, int *n1, int *n2, int *n3)
- {
- (*n1)=0;
- (*n2)=0;
- (*n3)=0;
-
- if (c->head==c->tail)
- return;
-
- (*n1)=c->message[c->tail].note1;
- (*n2)=c->message[c->tail].note2;
- (*n3)=c->message[c->tail].note3;
-
- inc_pointer(&c->tail);
-
- } /* void read_message(p_CHANNEL c, int *n1, int *n2, int *n3) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> BOOL any_messages(p_CHANNEL c)
- * PURPOSE : TRUE if any messages in queue, FALSE otherwise
- * :
- * CREATION: 02/10/1989 10:36:35
- */
- BOOL any_messages(p_CHANNEL c)
- {
- return( (c->head==c->tail) ? FALSE : TRUE);
- } /* BOOL any_messages(p_CHANNEL c) */